package com.picture.controller;


import com.picture.pojo.dto.PicturePageQueryDTO;
import com.picture.pojo.dto.PictureSaveDto;
import com.picture.pojo.entity.PictureTag;
import com.picture.pojo.vo.PictureTagVo;
import com.picture.result.PageResult;
import com.picture.result.Result;
import com.picture.service.PictureService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/picture")
@Api(tags = "图片相关接口")
@Slf4j
@CrossOrigin
public class PictureController {
    @Autowired
    PictureService pictureService;

    @PostMapping("/save")
    @ApiOperation("上传图片及其相关信息")
    public Result saveWithPicture(@RequestBody List<PictureSaveDto> pictureSaveDto){
        Result result=pictureService.saveWithPicture(pictureSaveDto);
        return Result.success();
    }

    @PostMapping("/list")
    @ApiOperation("根据分类查询图片")
    public Result<PageResult> picturelist(@RequestBody PicturePageQueryDTO picturePageQueryDTO){
        Result<PageResult> list= pictureService.picturelist(picturePageQueryDTO);
        return list;
    }
    @PostMapping("/tag")
    @ApiOperation("查询图片标记")
    public Result<List<PictureTag>>getTag(Long id){

        Result<List<PictureTag>> result= pictureService.getTag(id);
        return result;
    }

    @DeleteMapping("/delete")
    @ApiOperation("删除图片")
    public Result deletepicture(Long id){

        pictureService.delete(id);
        return Result.success();
    }
    @GetMapping("/exist")
    @ApiOperation("查看图片是否存在")
    public Result exist(Long id){

        pictureService.exist(id);
        return Result.success();
    }

    @GetMapping("/updatestatus")
    @ApiOperation("修改图片状态")
    public Result updatestatus(Long id){

        pictureService.updatestatus(id);
        return Result.success();
    }

}
